from django.db import models
from utils.models import BaseModel,CoreModel
from mysystem.models import Users
# Create your models here.
from utils.rabbitmq import RabbitMQ

class Project(CoreModel):
    name = models.CharField(max_length=50, verbose_name='名称')
    status = models.IntegerField(default=0,verbose_name="状态")
    filename = models.CharField(max_length=100,verbose_name="文件名")
    url = models.CharField(default="",max_length=100,verbose_name="导出文件")
    data = models.JSONField(default=[],verbose_name="导出文件")
    svg = models.TextField(default="",verbose_name="导出文件")
    width = models.IntegerField(default=0,verbose_name="文档宽度")
    height = models.IntegerField(default=0,verbose_name="文档高度")
    view_width = models.IntegerField(default=0,verbose_name="显示宽度")
    view_height = models.IntegerField(default=0,verbose_name="显示高度")
    offsetx = models.IntegerField(default=0,verbose_name="显示宽度")
    offsety = models.IntegerField(default=0,verbose_name="显示高度")
    sort = models.PositiveSmallIntegerField(default=0, verbose_name="排序", help_text="显示顺序")
    class Meta:
        db_table = 'tb_project'
        verbose_name = '项目名'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
    
    def save(self, *args, **kwargs):
        super(Project, self).save(*args, **kwargs)
        RabbitMQ(self.filename)